package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
<#if cfg.customTable == 'Y'>
import com.cloud.utils.ExcelPoiUtils;
import com.cloud.utils.ServletUtils;
import org.springframework.web.multipart.MultipartFile;
</#if>
import jakarta.annotation.Resource;
<#if cfg.customPort == 'Y'>
import java.util.List;
</#if>

/**
 * ${table.comment!}
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Resource
    private ${table.mapperName} ${'${table.mapperName}' ? uncap_first};

<#if cfg.customPort == 'Y'>
    /**
     * ${table.comment!}列表
     */
    @Override
    public List<${entity}> get${entity}List(${entity} ${'${entity}' ? uncap_first}){
        return ${'${table.mapperName}' ? uncap_first}.get${entity}List(${'${entity}' ? uncap_first});
    }

    /**
     * ${table.comment!}详情
     */
    @Override
    public ${entity} get${entity}ById(Long id){
        return ${'${table.mapperName}' ? uncap_first}.selectById(id);
    }

    /**
     * ${table.comment!}新增
     */
    @Override
    public int save${entity}(${entity} ${'${entity}' ? uncap_first}) {
        return ${'${table.mapperName}' ? uncap_first}.insert(${'${entity}' ? uncap_first});
    }

    /**
     * ${table.comment!}修改
     */
    @Override
    public int edit${entity}(${entity} ${'${entity}' ? uncap_first}) {
        return ${'${table.mapperName}' ? uncap_first}.updateById(${'${entity}' ? uncap_first});
    }

    /**
     * ${table.comment!}删除
     */
    @Override
    public int removeIds(List<Long> ids) {
        return ${'${table.mapperName}' ? uncap_first}.deleteBatchIds(ids);
    }
</#if>

<#if cfg.customTable == 'Y'>
    /**
     * ${table.comment!}导入
     */
    @Override
    public boolean importData(MultipartFile file) {
        List<${entity}> dataList = ExcelPoiUtils.importExcel(file,
        1, 1, ${entity}.class);
        return super.saveBatch(dataList);
    }

    /**
     * ${table.comment!}导出
     */
    @Override
    public void export(${entity} ${'${entity}' ? uncap_first}) {
        List<${entity}> dataList = get${entity}List(${'${entity}' ? uncap_first});
        if(dataList.size() > 0){
            String titleName = "${table.comment!}列表";
            ExcelPoiUtils.exportExcel(dataList, titleName, "${table.name}",
            ${entity}.class, titleName + ".xls", ServletUtils.getResponse());
        }
    }
</#if>
        
}
</#if>
